﻿namespace NetFx.SMIL.References
{
  using System;
  using System.Text;
  using System.Collections;
  using System.Collections.Generic;

  using System.Reflection;
  using System.Reflection.Emit;
  using System.Runtime.InteropServices;

  using System.Diagnostics;
  using System.Diagnostics.CodeAnalysis;
  using System.Diagnostics.SymbolStore;
  using System.Security;
  using System.Security.Permissions;

  using NetFx.MSIL;

  /// <summary>
  /// 标号的引用。
  /// </summary>
  public class LabelRef:ReflectRef
  {
    #region Statics
    public new static LabelRef it()
    {
      return new LabelRef();
    }
    public static LabelRef of(string identifier)
    {
      return new LabelRef(identifier);
    }
    public static LabelRef of(string identifier, Label? label)
    {
      return new LabelRef(identifier, label);
    }
    #endregion
    #region Properties
    /// <summary>
    /// 获取引用类型（为标号）。
    /// </summary>
    public override DefType ReflectionType
    {
      get { return DefType.Label; }
    }
    /// <summary>
    /// 获取反射信息。
    /// </summary>
    public virtual Label? ReflectInfo
    {
      get
      {
        return this.referenced != null ? 
          (Label?)this.referenced :
          null;
      }
    }
    public override bool HasReflectInfo
    {
      get
      {
        return this.ReflectInfo != null;
      }
    }
    #endregion
    #region Constructors
    public LabelRef() : base(null) { }
    public LabelRef(string identifier) : base(identifier) { }
    public LabelRef(string identifier, Label? label) : base(identifier, label) { }
    #endregion
    #region Methods
    protected override ReflectRef OnBinding(object source)
    {
      return base.OnBinding(source is Label? source:null);
    }
    public override string ToString()
    {
      return string.Format("{0}",this.Identifier);
    }
    #endregion
  }
}
